<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">酒店预约</span>
      <span @click="showBeautyBox = true">组件美化</span>
    </div>
    <div class="control-body">
      <div class="control-section">
        <!-- 主文本颜色 -->
        <colorControl
          :color.sync="params.params.mainColor"
          title="主文本颜色"
          @reset="resetItem('mainColor')"
          @change="setMainColor"
        ></colorControl>
        <!-- 副文本颜色 -->
        <colorControl
          :color.sync="params.params.subColor"
          title="副文本颜色"
          @reset="resetItem('subColor')"
          @change="setSubColor"
        ></colorControl>
        <!-- 线条颜色 -->
        <colorControl
          :color.sync="params.params.lineColor"
          title="线条颜色"
          @reset="resetItem('lineColor')"
          @change="setLineColor"
        ></colorControl>
      </div>
    </div>

    <!-- 组件美化 -->
    <comBeautyBox
      :showBeautyBox="showBeautyBox"
      @handleBack="showBeautyBox = false"
    >
      <div>
        <!-- 背景配置 -->
        <bgControl :backgroudData="params.moduleCss"></bgControl>
        <!-- 间距控制组件 -->
        <spaceControl
          :spaceData.sync="params.moduleCss"
          @resetSpace="resetSpace"
          @resetMp="resetMp"
        ></spaceControl>
      </div>
    </comBeautyBox>
  </div>
</template>

<script>
import { hotelSearch } from "@/components/DiyNew/diy/dataConfig/config.js";

import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";
import colorControl from "@/components/DiyNew/diy/baseControl/colorControl/index.vue";
import comBeautyBox from "@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue";
import spaceControl from "@/components/DiyNew/diy/baseControl/spaceControl/index.vue";

export default {
  name: "hotelSearchControl",
  components: {
    bgControl,
    colorControl,
    comBeautyBox,
    spaceControl,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showBeautyBox: false,
    };
  },
  watch: {},
  computed: {},
  methods: {
    setWithActionItem(e, key) {
      this.$setWithAction(this.params, key, e);
    },
    // 点击重置按钮
    resetItem(type) {
      let data = Object.assign({}, hotelSearch);
      this.$set(this.params.params, type, data.params[type]);
    },
    setMainColor(e) {
      console.log(e);
      this.$set(this.params.params, "mainColor", e);
    },
    setSubColor(e) {
      console.log(e);
      this.$set(this.params.params, "subColor", e);
    },
    setLineColor(e) {
      console.log(e);
      this.$set(this.params.params, "lineColor", e);
    },
    // 设置倒计时背景色
    setCountDownBgColor(e) {
      console.log(e);
      this.$set(this.params.params, "countDownBgColor", e);
    },
    // 设置倒计时文字颜色
    setCountDownFontColor(e) {
      console.log(e);
      this.$set(this.params.params, "countDownFontColor", e);
    },
    // 重置圆角
    resetSpace(e) {
      let type = e.type;
      console.log(type);
      this.$set(this.params.moduleCss, type, 0);
    },
    // 重置边距
    resetMp() {
      this.$set(this.params.moduleCss, "margin", 0);
      this.$set(this.params.moduleCss, "padding", 0);
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    padding-bottom: 20px;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
        }
        .control-content {
          .example-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .example-item {
              width: 70px;
              height: 44px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 6px;
              margin-bottom: 6px;
              display: flex;
              justify-content: center;
              align-items: center;
              cursor: pointer;
              img {
                width: 42px;
              }
            }
            .example-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
        }
      }
      .justify-section,
      .start-section {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          display: flex;
          align-items: center;
          .justify-select {
            width: 100%;
            height: 100%;
            ::v-deep .ant-select-selection--single {
              height: 100%;
              border: 0 none;
              background: #f2f2f2;
            }
            ::v-deep .ant-select-selection__rendered {
              line-height: 40px;
            }
          }
        }
      }
      .start-section {
        .control-content {
          .time-picker {
            width: 100%;
            height: 40px;
            .time-icon {
              width: 18px;
              height: 18px;
              border-radius: 50%;
            }
            ::v-deep .ant-input {
              height: 40px;
              border: 0 none;
              background: #f6f7f9;
            }
          }
        }
      }
    }
  }
}
</style>
